﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
	private DLL.UploadFile.Component clsUploadFileComp;
	private DLL.Training.Component clsTrainingComp;
	private DLL.PicNews.Component clsPicNewsComp;
	private DLL.Courseware.Component clsCoursewareComp;
	private DLL.SupplyDemand.Component clsSupplyDemandComp;
	private DLL.Department.Component clsDepartmentComp;
	private DLL.DepartmentLink.Component clsDepartmentLinkComp;
	private DLL.User.Component clsUserComp;
	private DLL.TrainingOrganization.Component clsTrainingOrganizationComp;

	private DLL.Software.View clsSoftwareView;

	//private PX.Question.Component clsQuestionComp = new PX.Question.Component();

	public string pics, links, texts;

	//protected TextBox TbQueryFileName;
	/// <summary>
	/// 查询文件名字
	/// </summary>
	public string QueryFileName
	{
		get { return TbQueryFileName.Text.Trim(); }
	}
	/// <summary>
	/// 要查询的课件名称
	/// </summary>
	public string QueryCoursewareName
	{
		get { return TbQueryCoursewareName.Text.Trim(); }
	}

	protected void Page_Load(object sender, EventArgs e)
	{
		clsTrainingComp.TrainingCommencementState();
		clsTrainingComp.TrainingEndState();

		//if (!IsPostBack)
		//{
			ShowPXDT();
			ShowPXZX();
			//ShowApplyTraining();
			ShowCommencementTraining();
			
			ShowSupplyDemand();
			ShowCourseware();
			ShowBasic();
			//BindExpertGridView();		// 绑定大师之家数据
			ShowBasic(GrvBasic1, 8);		// 煤业公司基层动态
			ShowBasic(GrvBasic2, 11);		// 开滦股份基层动态
			ShowBasic(GrvBasic3, 32);		// 国际物流基层动态
			ShowBasic(GrvBasic5, 43);		// 物资公司基层动态
			ShowBasic(GrvBasic6, 45);		// 多种经营基层动态
			ShowBasic(GrvBasic7, 60);		// 服务公司基层动态
			ShowBasic(GrvBasic8, 72);		// 蔚州公司基层动态
			ShowBasic(GrvBasic9, 81);		// 内蒙公司基层动态
			ShowBasic(GrvBasic10, 82);		// 新疆公司基层动态
			ShowBasic(GrvBasic11, 91);		// 兴隆公司基层动态
			ShowBasic(GrvBasic12, 92);		// 国和汽车基层动态
			ShowBasic(GrvBasic13, 88);		// 开滦总院基层动态
			ShowBasic(GrvBasic14, 89);		// 能源学院基层动态
			ShowPolicy();		// 显示政策文件内容
			ShowTrainingOrganization();
			ShowGain();
			ShowCourseware1();
			ShowCourseware2();
			ShowCourseware3();
			ShowCourseware4();
			clsSoftwareView.ShowAll(GrvSoftware);
		//}
		ShowPicNews();
		//ShowFriendlyLink();
		SetUserLoginView();
		ShowTrainingInstitutions();
	}

	protected override void OnInit(EventArgs e)
	{
		clsUploadFileComp = new DLL.UploadFile.Component(Page);
		clsTrainingComp = new DLL.Training.Component(Page);
		clsPicNewsComp = new DLL.PicNews.Component(Page);
		clsCoursewareComp = new DLL.Courseware.Component(Page);
		clsSupplyDemandComp = new DLL.SupplyDemand.Component(Page);
		clsDepartmentComp = new DLL.Department.Component(Page);
		clsDepartmentLinkComp = new DLL.DepartmentLink.Component(Page);
		clsUserComp = new DLL.User.Component(Page);
		clsTrainingOrganizationComp = new DLL.TrainingOrganization.Component(Page);

		clsSoftwareView = new DLL.Software.View(Page);

		base.OnInit(e);

		GrvPXDT.RowDataBound += new GridViewRowEventHandler(GrvPXDT_RowDataBound);
		GrvPXZX.RowDataBound += new GridViewRowEventHandler(GrvPXZX_RowDataBound);
		GrvSupplyDemand.RowDataBound += new GridViewRowEventHandler(GrvSupplyDemand_RowDataBound);
		LBtnUserLogin.Click += new EventHandler(LBtnUserLogin_Click);
		LBtnPersonLogin.Click += new EventHandler(LBtnPersonLogin_Click);
		//GrvCourseware.RowDataBound += new GridViewRowEventHandler(GrvCourseware_RowDataBound);
		GrvCommencement.RowCommand += new GridViewCommandEventHandler(GrvCommencement_RowCommand);
		LBtnLogOut.Click += new EventHandler(LBtnLogOut_Click);
		//GrvBasic.RowDataBound += new GridViewRowEventHandler(GrvBasic_RowDataBound);
		GrvBasic1.RowDataBound += new GridViewRowEventHandler(GrvBasic1_RowDataBound);
		GrvPolicy.RowDataBound += new GridViewRowEventHandler(GrvPolicy_RowDataBound);
		GrvBasic2.RowDataBound += new GridViewRowEventHandler(GrvBasic2_RowDataBound);
		GrvBasic3.RowDataBound += new GridViewRowEventHandler(GrvBasic3_RowDataBound);
		GrvBasic4.RowDataBound += new GridViewRowEventHandler(GrvBasic4_RowDataBound);
		GrvBasic5.RowDataBound += new GridViewRowEventHandler(GrvBasic5_RowDataBound);
		GrvBasic6.RowDataBound += new GridViewRowEventHandler(GrvBasic6_RowDataBound);
		GrvBasic7.RowDataBound += new GridViewRowEventHandler(GrvBasic7_RowDataBound);
		GrvBasic8.RowDataBound += new GridViewRowEventHandler(GrvBasic8_RowDataBound);
		GrvBasic9.RowDataBound += new GridViewRowEventHandler(GrvBasic9_RowDataBound);
		GrvBasic10.RowDataBound += new GridViewRowEventHandler(GrvBasic10_RowDataBound);
		GrvBasic11.RowDataBound += new GridViewRowEventHandler(GrvBasic11_RowDataBound);
		GrvBasic12.RowDataBound += new GridViewRowEventHandler(GrvBasic12_RowDataBound);
		GrvBasic13.RowDataBound += new GridViewRowEventHandler(GrvBasic13_RowDataBound);
		GrvBasic14.RowDataBound += new GridViewRowEventHandler(GrvBasic14_RowDataBound);
		GrvGain.RowDataBound += new GridViewRowEventHandler(GrvGain_RowDataBound);
		GrvCourseware1.RowDataBound += new GridViewRowEventHandler(GrvCourseware_RowDataBound);
		GrvCourseware2.RowDataBound += new GridViewRowEventHandler(GrvCourseware_RowDataBound);
		GrvCourseware3.RowDataBound += new GridViewRowEventHandler(GrvCourseware_RowDataBound);
		GrvCourseware4.RowDataBound += new GridViewRowEventHandler(GrvCourseware_RowDataBound);
		LBtnQueryFile.Click += new EventHandler(LBtnQueryFile_Click);
		LBtnQueryCourseware.Click += new EventHandler(LBtnQueryCourseware_Click);
		GrvSoftware.RowDataBound += new GridViewRowEventHandler(GrvSoftware_RowDataBound);
	}

	void GrvSoftware_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		clsSoftwareView.AddLink((GridView)sender, e, 0);
	}

	void LBtnQueryCourseware_Click(object sender, EventArgs e)
	{
		Server.Transfer("QueryCourseware.aspx");
	}

	/// <summary>
	/// 文件查询按钮
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void LBtnQueryFile_Click(object sender, EventArgs e)
	{
		Server.Transfer("Query.aspx");
	}

	/// <summary>
	/// 成果展示
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvGain_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddLinkToGridView((GridView)sender, e, 1);
	}

	/// <summary>
	/// 能源学院基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic14_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 开滦总院基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic13_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 国和汽车基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic12_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 兴隆公司基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic11_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 新疆公司基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic10_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 内蒙公司基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic9_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 蔚州公司基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic8_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 服务公司基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic7_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 多种经营基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic6_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 物资公司基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic5_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	void GrvBasic4_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 国际物流基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic3_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 开滦股份基层动态
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic2_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	/// <summary>
	/// 政策文件GridView行绑定后事件处理函数
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvPolicy_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddLinkToGridView((GridView)sender, e, 1);
	}

	/// <summary>
	/// 煤业公司基层动态GridView行绑定事件后事件处理函数
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvBasic1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddBasicGridViewLink((GridView)sender, e, 0);
	}

	void GrvBasic_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddLinkToGridView((GridView)sender, e, 1);
	}

	/// <summary>
	/// 注销按钮
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void LBtnLogOut_Click(object sender, EventArgs e)
	{
		Session.Clear();
		Session.Abandon();
		//Response.Write( "<script language=javascript>window.location.href=document.URL; </script>" ); 
		SetUserLoginView();
		TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "注销成功！");
	}

	void GrvCommencement_RowCommand(object sender, GridViewCommandEventArgs e)
	{
		int nUserID = 0;
		int nTrainingID = 0;
		DLL.TrainingPerson.Component clsTrainingPersonComp = new DLL.TrainingPerson.Component(Page);

		if (e.CommandName == "Learn")
		{
			if (Session["UserID"] != null)
			{
				if (Session["UserID"].ToString() != "")
				{
					nUserID = Convert.ToInt32(Session["UserID"]);
					nTrainingID = Convert.ToInt32(e.CommandArgument.ToString());
					if (clsTrainingPersonComp.Check(nTrainingID, nUserID))
					{
						Response.Redirect("OnLineLearn.aspx?TrainingID="+nTrainingID.ToString()+"");
					}
					else
					{
						TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "对不起，您不在此培训班中！");
					}
				}
				else
				{
					TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "请登录！");
				}
			}
			else
			{
				TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "请登录！");
			}
		}
	}

	/// <summary>
	/// 课件
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void GrvCourseware_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		GridView gv = new GridView();
		int nCoursewareID = 0;

		gv = (GridView)sender;
		if (e.Row.RowIndex >= 0)
		{
			e.Row.Cells[1].Controls.Clear();
			HyperLink aLink = new HyperLink();

			nCoursewareID = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Value);


			//aLink.CssClass = "Read";
			aLink.Text = e.Row.Cells[1].Text;
			aLink.NavigateUrl = "~/DownloadCourseware.aspx?CoursewareID=" + nCoursewareID.ToString();
			aLink.Target = "_blank";

			e.Row.Cells[1].Controls.Add(aLink);
		}
	}

	/// <summary>
	/// 用工号、姓名和身份证号登录
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void LBtnPersonLogin_Click(object sender, EventArgs e)
	{
		DLL.User.Entity clsLoginPersonUser = new DLL.User.Entity();

		if (clsUserComp.CheckNoUserLogin(TbJobNumber.Text, TbPersonName.Text, TbIDCard.Text, ref clsLoginPersonUser))
		{
			Session["UserID"] = clsLoginPersonUser.ID;
			SetUserLoginView();
			TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "登录成功！");
		}
		else
		{
			TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "用户信息错！");
		}
	}

	/// <summary>
	/// 用用户名和密码登录系统
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void LBtnUserLogin_Click(object sender, EventArgs e)
	{
		DLL.User.Entity clsLoginUser = new DLL.User.Entity();

		if (clsUserComp.CheckLogin(TbUsername.Text, TbPassword.Text, ref clsLoginUser))
		{
			Session["UserID"] = clsLoginUser.ID;
			SetUserLoginView();
			TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "登录成功！");
			//Response.Write("<script language=javascript>window.location.href=document.URL; </script>"); 
		}
		else
		{
			TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "用户名或密码错！");
		}
	}

	void GrvSupplyDemand_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		int nSupplyDemandID = 0;
		GridView gv = new GridView();

		if (e.Row.RowIndex >= 0)
		{
			HyperLink hLink = new HyperLink();
			DLL.SupplyDemand.Entity clsSupplyDemand = new DLL.SupplyDemand.Entity();

			gv = (GridView)sender;
			nSupplyDemandID = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Value);
			clsSupplyDemand = clsSupplyDemandComp.GetOne(nSupplyDemandID);
			hLink = (HyperLink) e.Row.FindControl("HLinkSupplyDemand");
			hLink.Target = "_blank";
			hLink.Text = "[" + clsSupplyDemand.TypeName + "]" + clsSupplyDemand.Name;
			hLink.ToolTip = clsSupplyDemand.Name;
			hLink.NavigateUrl = "~/ShowFileDetail.aspx?FileContentID=" + clsSupplyDemand.FileContentID.ToString();
		}
	}

	void GrvPXZX_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddLinkToGridView((GridView)sender, e, 0);
	}

	void GrvPXDT_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		AddLinkToGridView((GridView)sender, e, 1);
	}

	private void AddLinkToGridView(GridView gv, GridViewRowEventArgs e, int nStartIndex)
	{
		int nUploadFileID;

		if (e.Row.RowIndex >= 0)
		{
			for (int i = nStartIndex; i < e.Row.Cells.Count - 1; i++)
			{
				//if ((i != 0)  (i != (e.Row.Cells.Count - 1)))


				//LinkButton lBtnRead2 = new LinkButton();

				//lBtnRead2.Text = e.Row.Cells[i].Text;
				//lBtnRead2.CommandArgument = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
				//lBtnRead2.CommandName = lBtnRead.CommandName;
				//lBtnRead2.CssClass = lBtnRead.CssClass;
				e.Row.Cells[i].Controls.Clear();
				HyperLink aLink = new HyperLink();

				nUploadFileID = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Value);


				aLink.CssClass = "Read";
				aLink.Text = e.Row.Cells[i].Text;
				aLink.ToolTip = aLink.Text;
				//aLink.NavigateUrl = "../ShowImageContent.aspx?FileID=" + ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
				aLink.NavigateUrl = "~/ShowFileDetail.aspx?FileContentID=" + clsUploadFileComp.GetOne(nUploadFileID).FileContentID.ToString();
				aLink.Target = "_blank";

				e.Row.Cells[i].Controls.Add(aLink);

			}
		}
	}

	/// <summary>
	/// 显示培训动态文件
	/// </summary>
	/// <![CDATA[2014-8-20 18:00:45]]>
	private void ShowPXDT()
	{

		GrvPXDT.DataSource = clsUploadFileComp.QueryByWebColumnID(1);
		GrvPXDT.DataKeyNames = new string[] { "ID" };
		GrvPXDT.DataBind();
	}
	/// <summary>
	/// 显示培训资讯文件
	/// </summary>
	/// <![CDATA[2014-8-20 21:29:25]]>
	private void ShowPXZX()
	{

		GrvPXZX.DataSource = clsUploadFileComp.QueryByWebColumnID(10);
		GrvPXZX.DataKeyNames = new string[] { "ID" };
		GrvPXZX.DataBind();
	}
	/// <summary>
	/// 显示所有可以报名的培训班
	/// </summary>
	//private void ShowApplyTraining()
	//{
	//        GrvApplyTraining.DataSource = clsTrainingComp.QueryApplyTraining();
	//        GrvApplyTraining.DataKeyNames = new string[] { "ID" };
	//        GrvApplyTraining.DataBind();
	//}
	/// <summary>
	/// 显示已经开办的培训班
	/// </summary>
	private void ShowCommencementTraining()
	{
		GrvCommencement.DataSource = clsTrainingComp.QueryCommencementTraining();
		GrvCommencement.DataKeyNames = new string[] { "ID" };
		GrvCommencement.DataBind();
	}

	/// <summary>
	/// 显示图片新闻
	/// </summary>
	private void ShowPicNews()
	{
		List<DLL.PicNews.Entity> listPicNews = new List<DLL.PicNews.Entity>();

		listPicNews = clsPicNewsComp.QueryAll();
		for (int i = 0; i < 5; i++)
		{
			pics = pics + "ShowFileContent.aspx?FileContentID=" + listPicNews[i].PicContentID.ToString() + "|";
			links = links + "ShowFileContent.aspx?FileContentID=" + listPicNews[i].FileContentID.ToString() + "|";
			texts = texts + listPicNews[i].FileName + "|";
		}

		links = links.Substring(0, links.LastIndexOf("|"));
		pics = pics.Substring(0, pics.LastIndexOf("|"));
		texts = texts.Substring(0, texts.LastIndexOf("|"));
	}

	/// <summary>
	/// 用GridView显示一个类别的课件
	/// </summary>
	/// <param name="gv">显示课件的GridView</param>
	/// <param name="nCoursewareSortID">课件类别</param>
	private void ShowCourseware(GridView gv, int nCoursewareSortID)
	{
		gv.DataSource = clsCoursewareComp.Query(nCoursewareSortID);
		gv.DataKeyNames = new string[] { "ID" };
		gv.DataBind();
	}

	/// <summary>
	/// 用GridView显示供求信息
	/// </summary>
	private void ShowSupplyDemand()
	{
		GrvSupplyDemand.DataSource = clsSupplyDemandComp.QueryAll();
		GrvSupplyDemand.DataKeyNames = new string[] { "ID" };
		GrvSupplyDemand.DataBind();
	}

	/// <summary>
	/// 用GridView显示政策文件
	/// </summary>
	private void ShowPolicy()
	{
		GrvPolicy.DataSource = clsUploadFileComp.QueryByWebColumnID(11);
		GrvPolicy.DataKeyNames = new string[] { "ID" };
		GrvPolicy.DataBind();
	}

	/// <summary>
	/// 绑定成果展示
	/// </summary>
	private void ShowGain()
	{
		GrvGain.DataSource = clsUploadFileComp.QueryByWebColumnID(16);
		GrvGain.DataKeyNames = new string[] { "ID" };
		GrvGain.DataBind();
	}

	/// <summary>
	/// 用GridView显示基层单位信息
	/// </summary>
	/// <param name="gv"></param>
	/// <param name="nDepartmentID">二级单位ID</param>
	private void ShowBasic(GridView gv, int nDepartmentID)
	{
		string strChildDepartmentIDs = "";

		strChildDepartmentIDs = clsDepartmentComp.QueryChildDepartmentID(nDepartmentID);
		gv.DataSource = clsUploadFileComp.QueryByDepartmentIDs(strChildDepartmentIDs);
		gv.DataKeyNames = new string[] { "ID" };
		gv.DataBind();
	}

	/// <summary>
	/// 给基层单位的GridView添加显示文件内容超链接
	/// </summary>
	private void AddBasicGridViewLink(GridView gv, GridViewRowEventArgs e, int nStartIndex)
	{
		int nUploadFileID;

		if (e.Row.RowIndex >= 0)
		{
			for (int i = nStartIndex; i < e.Row.Cells.Count - 1; i++)
			{
				e.Row.Cells[i].Controls.Clear();
				HyperLink aLink = new HyperLink();

				nUploadFileID = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Value);


				aLink.CssClass = "Read";
				aLink.Text = e.Row.Cells[i].Text;
				aLink.ToolTip = aLink.Text;
				//aLink.NavigateUrl = "../ShowImageContent.aspx?FileID=" + ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
				aLink.NavigateUrl = "~/ShowFileDetail.aspx?FileContentID=" + clsUploadFileComp.GetOne(nUploadFileID).FileContentID.ToString();
				aLink.Target = "_blank";

				e.Row.Cells[i].Controls.Add(aLink);

			}
		}
	}

	/// <summary>
	/// 用GridView显示课件
	/// </summary>
	private void ShowCourseware()
	{
		//GrvCourseware.DataSource = clsCoursewareComp.QueryAll();
		//GrvCourseware.DataKeyNames = new string[] { "ID" };
		//GrvCourseware.DataBind();
	}

	/// <summary>
	/// 显示管理课件
	/// </summary>
	private void ShowCourseware1()
	{
		GrvCourseware1.DataSource = clsCoursewareComp.Query(3);
		GrvCourseware1.DataKeyNames = new string[] { "ID" };
		GrvCourseware1.DataBind();
	}
	/// <summary>
	/// 显示技术课件
	/// </summary>
	private void ShowCourseware2()
	{
		GrvCourseware2.DataSource = clsCoursewareComp.Query(4);
		GrvCourseware2.DataKeyNames = new string[] { "ID" };
		GrvCourseware2.DataBind();
	}
	/// <summary>
	/// 显示安全课件
	/// </summary>
	private void ShowCourseware3()
	{
		GrvCourseware3.DataSource = clsCoursewareComp.Query(5);
		GrvCourseware3.DataKeyNames = new string[] { "ID" };
		GrvCourseware3.DataBind();
	}
	/// <summary>
	/// 显示其它课件
	/// </summary>
	private void ShowCourseware4()
	{
		GrvCourseware4.DataSource = clsCoursewareComp.Query(8);
		GrvCourseware4.DataKeyNames = new string[] { "ID" };
		GrvCourseware4.DataBind();
	}

	/// <summary>
	/// 用GridView显示基层信息
	/// </summary>
	private void ShowBasic()
	{
		//GrvBasic.DataSource = clsUploadFileComp.QueryByWebColumnID(15);
		//GrvBasic.DataKeyNames = new string[] { "ID" };
		//GrvBasic.DataBind();
	}
	

	/// <summary>
	/// 设置用户登录出视图
	/// </summary>
	private void SetUserLoginView()
	{
		if (Session["UserID"] != null)
		{
			MVUserLogin.SetActiveView(VHaveLogin);
			LabPersonName.Text = "欢迎“" + clsUserComp.GetOne(Convert.ToInt32(Session["UserID"])).PersonName + "”回来！";
		}
		else
		{
			MVUserLogin.SetActiveView(VLogin);
		}
	}

	/// <summary>
	/// 绑定大师之家数据
	/// </summary>
	private void BindExpertGridView()
	{

		//clsQuestionComp.page = Page;
		//GrvExpert.DataSource = clsQuestionComp.QueryAll();
		//GrvExpert.DataKeyNames = new string[] { "ID" };
		//GrvExpert.DataBind();
	}

	/// <summary>
	/// 用菜单显示单位链接
	/// </summary>
	private void ShowTrainingInstitutions()
	{
		DLL.DepartmentLink.Component clsDepartmentLinkComp = new DLL.DepartmentLink.Component(Page);
		List<DLL.DepartmentLink.Entity> listDepartmentLink = new List<DLL.DepartmentLink.Entity>();

		listDepartmentLink = clsDepartmentLinkComp.QueryNoParent();
		MenuTrainingInstitutions.Items.Clear();
		for (int i = 0; i < listDepartmentLink.Count; i++)
		{
			MenuItem mItemChild = new MenuItem();

			mItemChild.Text = listDepartmentLink[i].DepartmentName;
			mItemChild.NavigateUrl = listDepartmentLink[i].Link;
			mItemChild.Target = "_blank";

			ShowChildDepartmentLink(mItemChild, listDepartmentLink[i].ID);

			//mItem.ChildItems.Add(mItemChild);
			MenuTrainingInstitutions.Items.Add(mItemChild);
		}
	}
	private void ShowChildDepartmentLink(MenuItem mItem, int nParentID)
	{
		DLL.DepartmentLink.Component clsDepartmentLinkComp = new DLL.DepartmentLink.Component(Page);
		List<DLL.DepartmentLink.Entity> listDepartmentLink = new List<DLL.DepartmentLink.Entity>();

		listDepartmentLink = clsDepartmentLinkComp.QueryByParentID(nParentID);
		for (int i = 0; i < listDepartmentLink.Count; i++)
		{
			MenuItem mItemChild = new MenuItem();

			mItemChild.Text = listDepartmentLink[i].DepartmentName;
			mItemChild.NavigateUrl = listDepartmentLink[i].Link;
			mItemChild.Target = "_blank";
			//mItemChild.SeparatorImageUrl = "../App_Themes/DefaultV2/Images/DepartmentLinkSeparator.png";

			ShowChildDepartmentLink(mItemChild, listDepartmentLink[i].ID);

			mItem.ChildItems.Add(mItemChild);
		}
	}

	/// <summary>
	/// 显示培训机构
	/// </summary>
	private void ShowTrainingOrganization()
	{
		List<DLL.TrainingOrganization.Entity> list = new List<DLL.TrainingOrganization.Entity>();

		MenuTrainingOrganization.Items.Clear();
		list = clsTrainingOrganizationComp.QueryAll();

		for (int i = 0; i < list.Count; i++)
		{
			MenuItem mItem = new MenuItem();

			mItem.Text = list[i].Name;
			mItem.NavigateUrl = list[i].Link;
			mItem.Target = "_blank";

			MenuTrainingOrganization.Items.Add(mItem);
		}
	}

	
}